package org.neframework.webtest.base;

import java.util.HashMap;
import java.util.Map;

import org.neframework.webtest.service.LogService;

import com.tmsps.neframework.core.common.page.Page;
import com.tmsps.neframework.jpa.sql.OrmComponent;
import com.tmsps.neframework.jpa.sql.param.NeParamList;
import com.tmsps.neframework.mvc.core.NeBaseController;
import com.tmsps.neframework.mvc.plugin.Tip;

/**
 * 继承自 NeBaseController,扩展了数据库操作
 * 
 * @author 冯晓东
 *
 */
public class BaseController extends NeBaseController {

	private LogService logService = null;
	public final OrmComponent oc = new OrmComponent();
	public NeParamList params = NeParamList.makeParams();

	public Page page = new Page();
	// 操作结果提示与说明(例如:操作成功)
	public Tip tip = new Tip();
	// 排序字段
	public Map<String, String> sort_params = new HashMap<String, String>();

	public void setTipMsg(String msg) {
		this.setTipMsg(msg, Tip.Type.information);
	}

	public void setTipMsg(String msg, Tip.Type type) {
		this.setTipMsg(true, msg, type);
	}

	public void setTipMsg(boolean b, String msg, Tip.Type type) {
		tip.setMsg(msg);
		tip.setType(type);

		result.put("success", b);
		result.put("tip", tip);
	}

	public LogService getLogService() {
		if (logService == null) {
			logService = new LogService(req);
		}
		return logService;
	}
}
